package com.woniuxy.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.entity.DTO.WarehousesDTO;
import com.woniuxy.mapper.WarehousesMapper;
import com.woniuxy.service.WarehousesService;
import com.woniuxy.util.PageParam;
import com.woniuxy.util.ResponseData;
import com.woniuxy.util.ResponseEnum;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class WarehousesServiceImpl implements WarehousesService {

    @Resource
    private WarehousesMapper warehousesMapper;

    @Override
    public List<WarehousesDTO> queryWarehousesInfo() {
        return warehousesMapper.queryWarehousesInfo();
    }

    @Override
    public PageInfo<WarehousesDTO> queryWarehouseByCondition(PageParam<WarehousesDTO> pageParam) {
        PageHelper.startPage(pageParam.getPageNum(), pageParam.getPageSize());
        List<WarehousesDTO> warehousesDTOS = warehousesMapper.queryWarehouseByCondition(pageParam.getParam());
        return new PageInfo<>(warehousesDTOS);
    }

    @Override
    public Integer changeStatus(Integer id) {
            return warehousesMapper.changeStatus(id);
    }

    @Override
    public void addWarehouse(WarehousesDTO warehousesDTO) {
        warehousesMapper.addWarehouse(warehousesDTO);
    }

    @Override
    public WarehousesDTO getWarehouseDetail(Integer warehouseId) {
        return warehousesMapper.getWarehouseDetail(warehouseId);
    }

    @Override
    public void updateWarehouse(WarehousesDTO warehousesDTO) {
        warehousesMapper.updateWarehouse(warehousesDTO);
    }

    @Override
    public boolean isExistRiderOrCourier(Integer warehouseId) {
        return warehousesMapper.isExistRiderOrCourier(warehouseId);
    }
}
